package com.meitianhui.convenitenbuy.util;

/**
 * Created by Administrator on 2017/11/29.
 */

public class TimeUtils {

    /**
     * 更具时间返回的时间格式
     *
     * @param time
     * @return
     */
    public static String getFormatTime(long time) {
        if (time == 0) {
            return "00:00:00";
        }
        long day = time / (24 * 60 * 60);
        long hour = (time / (60 * 60) - day * 24);
        long min = ((time / (60)) - day * 24 * 60 - hour * 60);
        long s = (time - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
        String s_min = min + "";
        if (s_min.length() == 1) {
            s_min = "0" + s_min;
        }
        String s_s = s + "";
        if (s_s.length() == 1) {
            s_s = "0" + s_s;
        }
        String s_hour = "";
        if (hour <= 9) {
            s_hour = "0" + hour;
        } else {
            s_hour = hour + "";
        }
        if (day <= 0) {
            return s_hour + ":" + s_min + ":" + s_s;
        } else {
            return day + "天 " + s_hour + ":" + s_min + ":" + s_s;
        }
    }

}
